﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Collections
{
    class Program
    {
        static void Main(string[] args)
        {
            //string[] months = new string[]
            //{
            //    "Январь",
            //    "Февраль",
            //    "Март",
            //    "Апрель",
            //    "Май",
            //    "Июнь",
            //    "Июль",
            //    "Август",
            //    "Сентябрь",
            //    "Октябрь",
            //    "Ноябрь",
            //    "Декабрь"
            //};

            //string[] months2 = new string[14];
            //months.CopyTo(months2, 2);

            //Array.Sort(months);
            //Array.Reverse(months);
            //string[] reversedMonths = new string[12];

            //int n = 0;
            //foreach (var item in months)
            //{
            //    reversedMonths[n] = item.ToArray().Reverse().ToString();
            //    n++;
            //}

            //string[] startsFromA = Array.FindAll(months, x=> x[0] == 'А');

            //foreach (var item in startsFromA)
            //{
            //    Console.WriteLine(item);
            //}

            Car c1 = new Car("Mercedes",    "Blue",     10000,  1990, "5600");
            Car c2 = new Car("Audi",        "Red",      20000,  1992, "A3");
            Car c3 = new Car("Renault",     "Black",    5000,   1998, "Duster");
            Car c4 = new Car("BMW",         "Black",    40000,  2000, "X5");
            Car c5 = new Car("BMW",         "Red",      45000,  2003, "X6");
            Car c6 = new Car("Audi",        "Silver",   35000,  1998, "A3");
            Car c7 = new Car("BMW",         "White",    33000,  2003, "i3");
            Car c8 = new Car("Mazda",       "White",    22000,  2004, "6");
            Car c9 = new Car("Mazda",       "Blue",     24000,  2004, "3");

            List<Car> carList = new List<Car>();
            carList.Add(c1);
            carList.Add(c2);
            carList.Add(c3);
            carList.Add(c4);
            carList.Add(c5);
            carList.Add(c6);
            carList.Add(c7);
            carList.Add(c8);
            carList.Add(c9);

            Car[] carArray = carList.ToArray();

            Car[] onlyBMWList = Array.FindAll(carArray, c => c.brand == "BMW");

            Car[] over30KList = Array.FindAll(carArray, c => c.price > 30000);

            Car[] audiA3List = Array.FindAll(carArray, c => c.brand == "Audi" && c.model == "A3");

            Car[] nonAudiMidPriceList = Array.FindAll(carArray, c => c.brand != "Audi" && c.price > 15000 && c.price <50000 && c.color != "Red");



            foreach (var item in nonAudiMidPriceList)
            {
                Console.WriteLine(item);
            }

        }

        class Car
        {
            public string brand ;
            public string color;
            public int price;
            public int year;
            public string model;

            public Car(string brand, string color, int price, int year, string model)
            {
                this.brand = brand;
                this.price = price;
                this.color = color;
                this.year = year;
                this.model = model;
            }

            public override string ToString()
            {
                StringBuilder srtBuild = new StringBuilder(this.brand+"\t"+ this.model + "\t" + this.color + "\t" + this.year + "\t" + this.price);
                return srtBuild.ToString();
            } 
        }
    }
}
